const gulp = require('gulp')
const uglify = require('gulp-uglify')
const minifyCSS = require('gulp-minify-css')
const imagemin = require('gulp-imagemin')


gulp.task('script', _ => {
    gulp.watch('js/*.js').on('change', event => {
        console.log(event.path)
        gulp.src('js/*.js')
            .pipe(uglify())
            .pipe(gulp.dest('test/js'))
    })
})

gulp.task('css', _ => {
    gulp.watch('css/*.css').on('change', _ => {
        gulp.src('css/*.css')
            .pipe(minifyCSS())
            .pipe(gulp.dest('test/css'))
    })
})

gulp.task('img', _ => {
    gulp.watch('img/*.*').on('change', _ => {
        gulp.src('img/*.*')
            .pipe(imagemin())
            .pipe(gulp.dest('test/img'))
    })
})

gulp.task('default', ['script', 'css', 'img'])